<?php

use think\facade\Route;

//TODO 使用/text/:id 类型路由名时，路由表需添加为 text/<id>
Route::group('/v1', function ()
{
    //登入
    Route::post('/login', 'AuthController/adminLogin');

    //上传文件
    Route::post('/files', 'FilesController/upload');

    //需要登入的api
    Route::group('',function ()
    {
        //控制节点
        Route::PUT('/routes/:id', 'RoutesController/editRoute')->model(\app\model\Routes::class);
        Route::post('/routes', 'RoutesController/addRoute');
        Route::delete('/routes/:id', 'RoutesController/delRoute')->model(\app\model\Routes::class);
        Route::get('/routes/:id', 'RoutesController/getById')->model(\app\model\Routes::class);
        Route::get('/routes', 'RoutesController/getRoute');

        Route::group('' , function (){
            // 通过id获取酒店信息
            Route::get('/hotel/:id' , 'HotelController/getHotel');
            // 禁用酒店
            Route::put('/hotel/status/:id' , 'HotelController/banHotel');
            // 修改酒店信息
            Route::put('/hotel/:id' , 'HotelController/editHotel');
        })->model('\app\model\Hotel');
        // 获取酒店列表
        Route::get('/hotel' , 'HotelController/getHotelList');
        // 新建酒店信息
        Route::post('/hotel' , 'HotelController/addHotel');

        Route::group('' , function (){
            // RoomType
            Route::group('' , function (){
                Route::get('/RoomType/:id' , 'RoomTypeController/getRoomType');
                Route::put('/RoomType/:id' , 'RoomTypeController/editRoomType');
                Route::delete("/RoomType/:id" , 'RoomTypeController/deleteRoomType');
            })->model('\app\model\RoomType');
            Route::get('/all/RoomType' , 'RoomTypeController/getRoomTypeAll');
            Route::get('/RoomType' , 'RoomTypeController/getRoomTypeList');
            Route::post('/RoomType' , 'RoomTypeController/addRoomType');
        });

        Route::group('' , function (){
            // Room
            Route::group('' , function (){
                Route::get('/Room/:id' , 'RoomController/getRoom');
                Route::put('/Room/:id' , 'RoomController/editRoom');
                Route::delete('/Room/:id' , 'RoomController/deleteRoom');
            })->model('\app\model\Room');
            Route::get('/Room' , 'RoomController/getRoomList');
            Route::post('/Room' , 'RoomController/addRoom');
        });

        Route::group('' , function (){
           Route::group('' , function (){
               Route::get('/RoomPassword/:id' , 'RoomPasswordController/getRoomPassword');
               Route::put('/RoomPassword/:id' , 'RoomPasswordController/editRoomPassword');
               Route::delete('/RoomPassword/:id' , 'RoomPasswordController/delRoomPassword');
           })->model('\app\model\RoomPassword');
            Route::get('/RoomPassword' , 'RoomPasswordController/getRoomPasswordList');
            Route::post('/RoomPassword' , 'RoomPasswordController/addRoomPassword');
        });
    })->middleware(\app\middleware\JwtAuth::class);
});
